SSH_HOST_EGDE="root@119.91.199.204"
WORK_DIR="/root/www"
PORT="22"

# build
    echo "*******Start to git pull*******"
    git pull
    echo "*******Start to build*******"
    npm run build
    ret=$?
        if [[ ${ret} -ne 0 ]] ; then
            echo 'Failed to build'
            exit ${ret}
        fi

    # upload dist to EGDE
    echo "*******Start to upload dist to ${SSH_HOST_EGDE}*******"
    scp -P ${PORT} -r dist ${SSH_HOST_EGDE}:${WORK_DIR}/bak
    ret=$?
    if [[ ${ret} -ne 0 ]] ; then
        echo "Failed to scp dist to ${SSH_HOST_EGDE}"
        exit ${ret}
    fi

    echo "*******delete dist*******"
    ssh -p ${PORT} ${SSH_HOST_EGDE} "cd ${WORK_DIR} ; rm -rf dist"

    echo "*******rename EGDE dist to html*******"
    ssh -p ${PORT} ${SSH_HOST_EGDE} "cd ${WORK_DIR} ; mv bak/dist ./dist"